<?php

require_once 'config.php';
require_once 'function.php';
require_once 'class/Mysql.class.php';

$db = new Mysql();

if( post('ispost') ){
	$ago = post('ago');
	$now = post('now');
	
	foreach( $ago as $k=>$v ){
		if( empty($v) || empty($now[$k]) ) continue;
		$db->update('product', array('product_cbsid'=>$now[$k]), 'product_cbsid='.$v);
	}
	
	alert('替换成功！','change_cbsid.php');
	exit;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改CBS ID</title>
<style type="text/css">
.item{ border-bottom:1px solid #999;padding:5px;}
</style>
<script type="text/javascript" src="js/jquery-1.6.2.js"></script>
<script type="text/javascript">
$(function(){
	add();	
})

function add(){
	$("#list").append( $("#demo").html() );	
}
</script>
</head>

<body>
<a href="javascript:add();">添加替换项</a> 空白项将被忽略
<br /><br />
<form method="post">
<div id="list"></div>
<br />
<input type="submit" value="提交" />
<input type="hidden" value="1" name="ispost" />
</form>
<div id="demo" style="display:none;">
<div class="item">原CBS ID：<input type="text" size="8" name="ago[]" /> 替换为：<input type="text" size="8" name="now[]" /></div>
</div>
</body>
</html>
